// 这应该是二次封装的 axios
import { get } from '@/utils/request.js'
const URL = 'http://api.music.20020202.xyz'
// const URL = 'http://localhost:3000'

const api = {
  /* 获取所有榜单 */
  getTopList() {
    const url = `${URL}/toplist/detail`
    return get(url)
  },

  // 获取歌单详情
  getPlaylistDetails(id) {
    const url = `${URL}/playlist/detail?id=${id}`
    return get(url)
  },

  // 获取歌单所有歌曲
  getMusicList(id, limit = 50, offset = 0) {
    const url = `${URL}/playlist/track/all?id=${id}&limit=${limit}&offset=${offset}`
    return get(url)
  },

  // 获取歌曲详情
  getMusic(ids) {
    const url = `${URL}/song/detail?ids=${ids}`
    return get(url)
  },

  // 获取歌词
  getMusicLyric(id) {
    const url = `${URL}/lyric?id=${id}`
    return get(url)
  },

  // 获取音乐播放地址
  getMusicPlay(id) {
    const url = `https://music.163.com/song/media/outer/url?id=${id}.mp3`
    return url
  },

  // 获取轮播图
  getSlideshow() {
    const url = URL + '/banner'
    return get(url)
  },

  // 获取每日推荐歌单
  getRecommend() {
    const url = URL + '/recommend/resource'
    return get(url)
  },

  // 手机登录
  phoneLogin(phone, password) {
    const url = `${URL}/login/cellphone?phone=${phone}&password=${password}`
    return get(url)
  },

  // 获取用户信息
  getUser(uid) {
    const url = `${URL}/user/detail?uid=${uid}`
    return get(url)
  },

  // 获取用户歌单
  getUserPlaylist(uid) {
    const url = `${URL}/user/playlist?uid=${uid}`
    return get(url)
  },

  // 搜索
  getSearch(val, limit = 50, offset = 0) {
    const url = `${URL}/cloudsearch?keywords=${val}&limit=${limit}&offset=${offset}`
    return get(url)
  },

  // 热搜列表
  getHotSearch() {
    const url = `${URL}/search/hot/detail`
    return get(url)
  },
}

export default api
